home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 32 / Amiga Format AFCD32 (Nov 1998, Issue 117).iso / -seriously_amiga- / programming / other / hrtmon / src / cmd_sp.s < prev    next >
Text File  |  1998-08-10  |  5KB  |  239 lines

  1.  
  2. ;HRTmon Amiga system monitor
  3. ;Copyright (C) 1991-1998 Alain Malek Alain.Malek@cryogen.com
  4. ;
  5. ;This program is free software; you can redistribute it and/or
  6. ;modify it under the terms of the GNU General Public License
  7. ;as published by the Free Software Foundation; either version 2
  8. ;of the License, or (at your option) any later version.
  9. ;
  10. ;This program is distributed in the hope that it will be useful,
  11. ;but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ;GNU General Public License for more details.
  14. ;
  15. ;You can find the full GNU GPL online at: http://www.gnu.org
  16.  
  17.  
  18. ;-------------- save the actual picture from the gfx-ripper --------------
  19.  
  20. cmd_sp
  21.         lea.l    ev_line,a1
  22.         bsr    read_name        ;get filename
  23.         tst.b    (a1)
  24.         beq.w    illegal_name
  25.  
  26.         tst.b    p_used
  27.         bne.b    .okp
  28.         lea.l    firstusep_txt(pc),a0
  29.         bsr    print
  30.         jmp    end_command
  31.  
  32. .okp        jsr    remove_pic
  33.  
  34.         move.l    #ev_line,d1        ;filename
  35.         moveq    #-1,d2            ;create mode
  36.         bsr    open_file
  37.         move.l    d0,d7            ;filehandle
  38.         beq.w    .error
  39.  
  40. ;-------------- write header+BMHD ----------
  41.  
  42.         move.w    #-1,ts_size        ;trainer buffer cleared
  43.  
  44.         lea.l    IFF_header,a0
  45.         lea.l    tmp_mem,a1
  46.         move.w    #(IFF_header_end-IFF_header),d0
  47.         lsr.w    #1,d0
  48.         subq.w    #1,d0
  49. .copyh        move.w    (a0)+,(a1)+        ;copy IFF_header
  50.         dbf    d0,.copyh
  51.  
  52.         lea.l    tmp_mem,a0
  53.         movem.w    width,d0-d1
  54.         movem.w    d0-d1,IFF_header_bmhdstart-IFF_header(a0)
  55.         movem.w    d0-d1,IFF_header_bmhdstart-IFF_header+16(a0)
  56.         move.w    depth,d0
  57.         move.b    d0,IFF_header_bmhdstart-IFF_header+8(a0)
  58.  
  59.         move.l    d7,d1
  60.         move.l    #tmp_mem,d2
  61.         move.l    #IFF_header_end-IFF_header,d3
  62.         bsr    write_file        ;write header
  63.  
  64. ;-------------- write CAMG if HAM mode ----------
  65.  
  66.         tst.b    ham
  67.         beq.b    .noham3
  68.         lea.l    tmp_mem,a0
  69.         move.l    #"CAMG",(a0)+
  70.         move.l    #4,(a0)+
  71.         move.l    #$800,(a0)+
  72.         move.l    d7,d1
  73.         move.l    #tmp_mem,d2
  74.         move.l    #3*4,d3
  75.         bsr    write_file        ;write CAMG
  76.  
  77.         cmp.w    #8,depth        ;HAM8 ?
  78.         bne.b    .noham3
  79.         lea.l    bitplan,a0
  80.         movem.l    (a0),d0-d1        ;rotate bitplans
  81.         move.l    2*4(a0),(a0)
  82.         move.l    3*4(a0),1*4(a0)
  83.         move.l    4*4(a0),2*4(a0)
  84.         move.l    5*4(a0),3*4(a0)
  85.         move.l    6*4(a0),4*4(a0)
  86.         move.l    7*4(a0),5*4(a0)
  87.         movem.l    d0-d1,6*4(a0)
  88.         bra.b    .okham
  89. .noham3
  90.         tst.b    ehb
  91.         beq.b    .noehb
  92.         cmp.w    #6,depth
  93.         bne.b    .noehb
  94.         move.l    #"CAMG",(a0)+
  95.         move.l    #4,(a0)+
  96.         move.l    #$80,(a0)+
  97.         move.l    d7,d1
  98.         move.l    #tmp_mem,d2
  99.         move.l    #3*4,d3
  100.         bsr    write_file        ;write CAMG for halfbright
  101. .noehb
  102. .okham
  103.  
  104. ;-------------- write CMAP+BODY header ----------
  105.  
  106.         lea.l    tmp_mem,a0
  107.         move.w    depth,d0
  108.         moveq    #1,d1
  109.         lsl.w    d0,d1            ;d1=nb colors
  110.         move.l    #"CMAP",(a0)+
  111.         move.w    d1,d2
  112.         muls    #3,d2
  113.         move.l    d2,(a0)+        ;CMAP size
  114.  
  115.         move.l    d7,-(a7)
  116.         lea.l    paletteH,a1
  117.         lea.l    paletteL,a2
  118.         moveq    #0,d7        ;color no
  119.         subq.w    #1,d1
  120. .loopc        move.w    custom+$10c,d0
  121.         lsr.w    #8,d0
  122.         eor.w    d7,d0
  123.         add.w    d0,d0
  124.         move.w    (a1,d0.w),d2
  125.         move.w    (a2,d0.w),d3
  126.         move.w    d2,d6
  127.         and.w    #$f,d6        ;H blue
  128.         lsl.w    #4,d6
  129.         move.w    d3,d0
  130.         and.w    #$f,d0        ;L blue
  131.         or.w    d0,d6        ;d6=BLUE
  132.  
  133.         move.w    d2,d5
  134.         and.w    #$f0,d5        ;H green
  135.         move.w    d3,d0
  136.         and.w    #$f0,d0
  137.         lsr.w    #4,d0        ;L green
  138.         or.w    d0,d5        ;d5=GREEN
  139.  
  140.         move.w    d2,d4
  141.         lsr.w    #4,d4
  142.         and.w    #$f0,d4        ;H red
  143.         move.w    d3,d0
  144.         lsr.w    #8,d0
  145.         and.w    #$f,d0        ;L red
  146.         or.w    d0,d4        ;d4=RED
  147.  
  148.         move.b    d4,(a0)+    ;save RED
  149.         move.b    d5,(a0)+    ;save GREEN
  150.         move.b    d6,(a0)+    ;save BLUE
  151.  
  152.         addq.w    #1,d7
  153.         dbf    d1,.loopc
  154.  
  155.         move.l    (a7)+,d7
  156.  
  157.         move.l    #"BODY",(a0)+
  158.         movem.w    width,d0-d1
  159.         lsr.w    #3,d0
  160.         mulu    depth,d0
  161.         mulu    d1,d0        ;d0=BODY size
  162.         move.l    d0,(a0)+
  163.  
  164.         move.l    d7,d1
  165.         move.l    #tmp_mem,d2
  166.         move.l    a0,d3
  167.         sub.l    d2,d3
  168.         bsr    write_file    ;write CMAP + BODY header
  169.  
  170. ;-------------- write bitplans --------
  171.  
  172.         movem.w    width,d4-d5
  173.         lsr.l    #3,d4        ;width in bytes
  174.         sub.l    a1,a1        ;offset
  175.         subq.w    #1,d5
  176. .next_line    lea.l    bitplan,a0
  177.         move.w    depth,d6
  178.         subq.w    #1,d6
  179. .next_plan    move.l    (a0)+,d2
  180.         add.l    a1,d2        ;add offset
  181.         move.l    d7,d1
  182.         move.l    d4,d3
  183.         bsr    write_file    ;write 1 line from 1 plan
  184.         dbf    d6,.next_plan
  185.         lea.l    40(a1),a1    ;inc offset to next line
  186.         add.w    modulo,a1
  187.         dbf    d5,.next_line
  188.  
  189. ;-------------- close file ------------
  190.  
  191.         move.l    d7,d1
  192.         moveq    #4,d2        ;offset (FORM size)
  193.         moveq    #-1,d3        ;offset from beginning
  194.         bsr    seek_file
  195.         move.l    d7,a0
  196.         move.l    file_size(a0),d0
  197.         subq.l    #8,d0        ;calc FORM size
  198.         move.l    d0,tmp_mem
  199.         move.l    d7,d1
  200.         move.l    #tmp_mem,d2
  201.         moveq    #4,d3
  202.         bsr    write_file    ;write FORM size
  203.  
  204.         move.l    d7,d1
  205.         bsr    close_file
  206.  
  207. .error        jsr    set_pic
  208.         move.w    #$2000,sr
  209.  
  210.         jmp    end_command
  211.  
  212. firstusep_txt    dc.b "First use P command !",$a,0
  213.         even
  214.  
  215.         cnop 0,4
  216.  
  217. IFF_header    dc.b "FORM"
  218.         dc.l 0            ;FORM size
  219.         dc.b "ILBM"
  220.         dc.b "ANNO"
  221.         dc.l .annoend-.annostart    ;ANNO size (always even !)
  222. .annostart    dc.b "File written by HRTmon v"
  223.         version
  224. .annoend
  225.         dc.b "BMHD"
  226.         dc.l IFF_header_bmhdend-IFF_header_bmhdstart    ;BMHD size
  227. IFF_header_bmhdstart    dc.w 0,0    ;width,height
  228.         dc.w 0,0        ;x,y pos
  229.         dc.b 0            ;depth
  230.         dc.b 0            ;mask (none)
  231.         dc.b 0            ;compression mode (none)
  232.         dc.b 0            ;align
  233.         dc.w 0            ;transparent color
  234.         dc.b $2c,$2c        ;xAspect,yAspect
  235.         dc.w 0,0        ;pageWidth,pageHeight
  236. IFF_header_bmhdend
  237. IFF_header_end
  238.  
  239.